package com.itheima.stock.controller;

import com.itheima.stock.service.UserService;
import com.itheima.stock.vo.LoginReqVo;
import com.itheima.stock.vo.LoginRespVo;
import com.itheima.stock.vo.R;
import com.itheima.stock.vo.UserRespVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/api")
@CrossOrigin
public class UserController {

    @Autowired
    private UserService userService;
    //使用spring-security故注释掉
  /*  @PostMapping("/login")
    public R<LoginRespVo> login(@RequestBody LoginReqVo vo){
       return userService.login(vo);
   } */

    /**
     * 生成验证码
     *  map结构：
     *      code： xxx,
     *      rkey: xxx
     * @return
     */
    @GetMapping("/captcha")
    public R<Map> generateCaptcha(){
        return this.userService.generateCaptcha();
    }

    /**
     * id查询用户信息
     *
     * @param id
     * @return
     */
    @GetMapping("/user/info/{userId}")
    public R<UserRespVo> selUserById(@PathVariable("userId") Long id) {
        return userService.selUserById(id);
    }

}
